namespace AdminSG3L.Applicaticn.ServicesInterface;

using AdminSG3L.Domain.Entities;
using AdminSG3L.Applicaticn.Commands;
using AdminSG3L.Applicaticn.Dtos;

/// <summary>
/// 角色服务接口，定义角色相关的应用层操作
/// </summary>
public interface IRoleService
{
    /// <summary>
    /// 创建新角色
    /// </summary>
    Task<ApiResponse<RoleDto>> CreateAsync(CreateRoleDto dto);

    /// <summary>
    /// 批量添加角色
    /// </summary>
    Task<ApiResponse<IEnumerable<RoleDto>>> BatchCreateAsync(IEnumerable<CreateRoleDto> dtos);

    /// <summary>
    /// 更新角色信息
    /// </summary>
    Task<ApiResponse<bool>> UpdateAsync(UpdateRoleDto dto);

    /// <summary>
    /// 删除角色
    /// </summary>
    Task<ApiResponse<bool>> DeleteAsync(Guid id);

    /// <summary>
    /// 批量删除角色
    /// </summary>
    Task<ApiResponse<int>> BatchDeleteAsync(IEnumerable<Guid> ids);

    /// <summary>
    /// 查询所有角色
    /// </summary>
    Task<ApiResponse<IEnumerable<RoleDto>>> GetAllDtoAsync();

    /// <summary>
    /// 分页查询角色
    /// </summary>
    Task<ApiResponse<(IEnumerable<RoleDto> Roles, int TotalCount)>> GetPagedDtoAsync(int pageIndex, int pageSize);
    
    /// <summary>
    /// 分页查询角色（带筛选）
    /// </summary>
    /// <param name="pageIndex">页码索引</param>
    /// <param name="pageSize">每页大小</param>
    /// <param name="filter">筛选条件</param>
    Task<ApiResponse<(IEnumerable<RoleDto> Roles, int TotalCount)>> GetPagedFilteredDtoAsync(int pageIndex, int pageSize, RoleFilterDto filter);

    /// <summary>
    /// 获取角色总数
    /// </summary>
    Task<ApiResponse<int>> GetCountAsync();

    /// <summary>
    /// 条件查询单个角色
    /// </summary>
    Task<ApiResponse<RoleDto?>> FindOneAsync(Func<RoleDto, bool> predicate);

    /// <summary>
    /// 条件查询多个角色
    /// </summary>
    Task<ApiResponse<IEnumerable<RoleDto>>> FindManyAsync(Func<RoleDto, bool> predicate);

    /// <summary>
    /// 给角色分配权限
    /// </summary>
    Task<ApiResponse<bool>> AssignPermissionAsync(Guid roleId, Guid permissionId);

    /// <summary>
    /// 移除角色权限
    /// </summary>
    Task<ApiResponse<bool>> RemovePermissionAsync(Guid roleId, Guid permissionId);

    /// <summary>
    /// 获取角色的所有权限
    /// </summary>
    Task<ApiResponse<IEnumerable<PermissionDto>>> GetRolePermissionsAsync(Guid roleId);

    /// <summary>
    /// 给角色分配菜单
    /// </summary>
    Task<ApiResponse<bool>> AssignMenuAsync(Guid roleId, Guid menuId);

    /// <summary>
    /// 移除角色菜单
    /// </summary>
    Task<ApiResponse<bool>> RemoveMenuAsync(Guid roleId, Guid menuId);

    /// <summary>
    /// 获取角色的菜单列表
    /// </summary>
    Task<ApiResponse<IEnumerable<object>>> GetRoleMenusAsync(Guid roleId);

    /// <summary>
    /// 修改角色启用状态
    /// </summary>
    Task<ApiResponse<bool>> SetEnabledAsync(Guid roleId, bool enabled);

    Task<ApiResponse<RoleDto?>> GetDtoByIdAsync(Guid id);
} 